<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>socket</title>
    <link rel="stylesheet" href="../../model/element.css">
    <link rel="stylesheet" href="../../model/jsFn.css">
</head>
<body>
<div class="catalog">
    <h1>目录</h1>
    <ul>
        <li>
            <p><a href="#profile">io</a></p>
            <ul>
                <li><p><a href="#jsFn_io">io</a></p></li>
            </ul>
        </li>
        <li>
            <p><a href="#profile_socket">socket</a></p>
            <ul>
                <li><p><a href="#jsFn_socket.on">on</a></p></li>
                <li><p><a href="#jsFn_socket.emit">emit</a></p></li>
                <li><p><a href="#jsFn_socket.connect">connect</a></p></li>
                <li><p><a href="#jsFn_socket.disconnect">disconnect</a></p></li>
            </ul>
        </li>
    </ul>
</div>
<div id="profile">
    <h2>对象简介:</h2>
    <p>io流</p>
</div>
<div class="jsFnModel" id="jsFn_io">
    <h3>io:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>io(url) -> socket</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>获得一个socket</p>
    </div>
    <div class="version">
        <p>${稳定性;2 - 稳定的}</p>
        <p>${新增于:v0.0.0}</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <ul>
            <li>
                <p>url</p>
                <p>&nbsp;string&nbsp;</p>
                <p>指定连接的地址</p>
            </li>
        </ul>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>socket</p>
        <p>参考 <a href="#profile_socket">socket</a></p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                let socket = io('http://193.22.22.22:1111');
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div id="profile_socket">
    <h2>对象简介:</h2>
    <p>socket网络连接</p>
</div>
<div class="jsFnModel" id="jsFn_socket.on">
    <h3>on:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>socket.on(event,fn) -> null</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>设置一个socket监听</p>
    </div>
    <div class="version">
        <p>稳定性;2 - 稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <ul>
            <li>
                <p>event</p>
                <p>&nbsp;string&nbsp;</p>
                <p>监听一个事件</p>
            </li>
            <li>
                <p>fn</p>
                <p>&nbsp;function&nbsp;</p>
                <p>监听事件触发后指定的方法,fn(message),message:object,收到的消息</p>
            </li>
        </ul>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>无</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                let socket = io(url);
                socket.on("chat",(message)=>{
                    console.log("收到新消息啦");
                });
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="jsFnModel" id="jsFn_socket.emit">
    <h3>emit:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>socket.emit("event",data,fn) -> null</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>给服务端发送消息</p>
    </div>
    <div class="version">
        <p>稳定性;2 - 稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <ul>
            <li>
                <p>event</p>
                <p>&nbsp;string&nbsp;</p>
                <p>事件的名称</p>
            </li>
            <li>
                <p>data</p>
                <p>&nbsp;fn&nbsp;</p>
                <p>发送给服务器的数据</p>
            </li>
            <li>
                <p>fn</p>
                <p>&nbsp;function&nbsp;</p>
                <p>发送成功后指定的方法fn(message),message:object</p>
            </li>
        </ul>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>无</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                socket.emit("sendMessage",{message:'你好'},(message)=>{
                    console.log("发送成功");
                });
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="jsFnModel" id="jsFn_socket.connect">
    <h3>connect:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>socket.connect() -> null</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>发起连接</p>
    </div>
    <div class="version">
        <p>稳定性;2 - 稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <p>无</p>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>无</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                socket.connect();
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="jsFnModel" id="jsFn_socket.disconnect">
    <h3>disconnect:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>socket.disconnect() -> null</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>断开连接</p>
    </div>
    <div class="version">
        <p>稳定性;2 - 稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <p>无</p>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>无</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                socket.disconnect();
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="author">
    <p>by-草草</p>
</div>
</body>
</html>